package com.tanhua.server.controller;

import com.tanhua.domain.vo.PageResult;
import com.tanhua.server.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/smallVideos")
public class VideoController {


    @Autowired
    private VideoService videoService;

    @PostMapping(name = "上传小视频")
    public ResponseEntity uploadVideo(MultipartFile videoThumbnail,MultipartFile videoFile) throws Exception{
        return videoService.uploadVideo(videoThumbnail,videoFile);
    }

    @GetMapping(name = "分页查询小视频列表")
    public ResponseEntity queryVideo( @RequestParam(defaultValue = "1") Integer page,
                                      @RequestParam(defaultValue = "10")Integer pagesize) throws Exception{
        PageResult pageResult = videoService.queryVideo(page, pagesize);
        return ResponseEntity.ok(pageResult);
    }


    @PostMapping(value = "/{uid}/userFocus",name = "关注视频博主")
    public ResponseEntity userFocus( @PathVariable("uid") Long focusUserId) throws Exception{
        return videoService.userFocus(focusUserId);

    }
    @PostMapping(value = "/{uid}/userUnFocus",name = "取消关注视频博主")
    public ResponseEntity userUnFocus( @PathVariable("uid") Long focusUserId) throws Exception{




        return videoService.userUnFocus(focusUserId);

    }

}
